# Maintainer: Caleb Maclennan <caleb@alerque.com>

pkgname=xdg-desktop-portal-hyprland
pkgver=0.3.1
_protocolver=4d29e48433270a2af06b8bc711ca1fe5109746cd
pkgrel=1
pkgdesc='xdg-desktop-portal backend for hyprland'
url="https://github.com/hyprwm/$pkgname"
arch=(loong64 x86_64)
license=(MIT)
provides=(xdg-desktop-portal-impl)
depends=(libinih
         libuuid.so
         pipewire
         qt6-base
         qt6-wayland
         xdg-desktop-portal)
makedepends=(cmake
             meson
             scdoc
             wayland
             wayland-protocols)
optdepends=('grim: required for the screenshot portal to function'
            'slurp: support for interactive mode for the screenshot portal')
_archive="$pkgname-$pkgver"
source=("$url/archive/v$pkgver/v$pkgver.tar.gz"
        "https://github.com/hyprwm/hyprland-protocols/archive/$_protocolver.tar.gz")
sha256sums=('ecac494f37f94cead01276987a91a556c3fef253f2149eff5d7e06237e526fb3'
            '5f6be4d870e94314f05ec7ff9c9c1f028748230ff80a7f89aeaf66c08e5c70e0')

prepare() {
    cd "$_archive/subprojects"
    rm -rf hyprland-protocols
    ln -sfT "$srcdir/hyprland-protocols-$_protocolver" hyprland-protocols
}

build() {
    cd "$_archive"
    arch-meson -Dsd-bus-provider=libsystemd build
    ninja -C build
    make -C hyprland-share-picker all
}

package() {
    cd "$_archive"
    DESTDIR="$pkgdir" ninja -C build install
    install -Dm0755 -t "$pkgdir/usr/bin/" hyprland-share-picker/build/hyprland-share-picker
    install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE
}
